import Dialog from '../miniprogram_npm/@vant/weapp/dialog/dialog'
import { Resume } from '../models/resume'
import { Publish } from '../models/other'
const publishModel = new Publish()
const resumeModel = new Resume()


function getVirtualPhone(contentId, type, isMark) {
  // 获取虚拟手机号
  publishModel.getPhoneNumber({
    contentId,
    type
  }, res => {
    wx.makePhoneCall({
      phoneNumber: res.secretNo
    })
  })
}


function markCall(markInfo) {
  resumeModel.call(markInfo)
}


const Call = function (contentId, type, markInfo) {
  Dialog.confirm({
    message: '为了保证双方的隐私安全，拨打和收到的 均为虚拟隐私号码！'
  })
    .then(() => {
      if (markInfo) {
        markCall(markInfo)
      }
      getVirtualPhone(contentId, type)
    })
}


export default Call